@echo off
echo Checking JNI compilation issues...
echo.

echo 1. Checking NDK installation...
if exist "%ANDROID_HOME%\ndk" (
    echo NDK found in ANDROID_HOME
) else (
    echo NDK not found in ANDROID_HOME, checking local.properties...
)

echo.
echo 2. Checking CMakeLists.txt...
if exist "app\src\main\cpp\CMakeLists.txt" (
    echo CMakeLists.txt found
) else (
    echo CMakeLists.txt not found!
)

echo.
echo 3. Checking C++ source files...
if exist "app\src\main\cpp\can_native.cpp" (
    echo C++ source file found
) else (
    echo C++ source file not found!
)

echo.
echo 4. Checking build.gradle configuration...
findstr /C:"externalNativeBuild" app\build.gradle >nul
if %errorlevel%==0 (
    echo externalNativeBuild configuration found
) else (
    echo externalNativeBuild configuration not found!
)

echo.
echo 5. Common JNI compilation issues and solutions:
echo - Missing NDK: Install NDK through Android Studio SDK Manager
echo - Wrong CMake version: Use CMake 3.18.1 or compatible version
echo - Missing headers: Ensure all required headers are included
echo - ABI mismatch: Check ndk.abiFilters in build.gradle
echo - STL issues: Use c++_shared STL
echo.
echo 6. To fix compilation:
echo - Clean project: gradlew clean
echo - Rebuild: gradlew assembleDebug
echo - Check Android Studio Build Output for detailed errors
echo.
pause